<#include "/common/head.html">
<link rel="stylesheet" href="/ace/assets/css/ace.css" />
	<script src="/js/layer/layer.js"></script>
      	<script src="/js/jquery.ext.js"></script>
	<script src="/js/layer/extend/layer.ext.js"></script>
	<script src="/js/common.js"></script>
<body>
<div class="main-content">
    <div class="main-content-inner">
        <div class="page-content">
            <div class="row">
                <div class="col-xs-12">
                    <form id="dForm" method="post" action="/book/user/save" class="form-horizontal" role="form" enctype="multipart/form-data">
                    <input type="hidden" id="bid" name="bid" value="${book.bid!}">
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="bname" >书籍名称</label>
							<div class="col-sm-4">
								<input type="text" name="bname" value="${book.bname!}" id="bname" placeholder="请输入书籍名称" class="required"/>
							</div>
							<label class="col-sm-2 control-label no-padding-right" for="cid">书籍类别</label>
							<div class="col-sm-4">
								<select id="category" name="cid" class="col-xs-8">
									<#if categories??>	
										<#list categories as category>
											<#if book.cid??>	
											<#if category.cid==book.cid>
											<option value="${category.cid!}" selected="selected">${category.cname!}</option>
											<#else>
											<option value="${category.cid!}">${category.cname!}</option>
											</#if>
											<#else>
											<option value="${category.cid!}">${category.cname!}</option>
											</#if>
										</#list>
									</#if>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="codekindname">作者</label>
							<div class="col-sm-4">
								<input type="text" name="author" value="${book.author!}" id="author" placeholder="请输入作者" />
							</div>
							<label class="col-sm-2 control-label no-padding-right" for="remark">价格</label>
							<div class="col-sm-4">
								<input type="text" name="price" value="${book.price!}" id="price" placeholder="请输入价格" />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="codekindname">内容简介</label>
							<div class="col-sm-10">
								<textarea rows="3" cols="75" style="resize:none;" name="blurb">${book.blurb!}</textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="codekindname">图片地址</label>
							<div class="col-sm-10">
								<textarea rows="3" cols="75" style="resize:none;" name="image">${book.image!}</textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="codekindname">大图地址</label>
							<div class="col-sm-10">
								<textarea rows="3" cols="75" style="resize:none;" name="bigimage">${book.bigimage!}</textarea>
							</div>
						</div>
						<!--<#if book.image??>-->
						<!--<div class="form-group">-->
							<!--<label class="col-sm-2 control-label no-padding-right" for="codekindname">已上传图片</label>-->
							<!--<div class="col-xs-9">-->
								<!--<img alt="" src="${showImgUrl!}${book.image!}" height="100px" width="150px">-->
							<!--</div>-->
						<!--</div>-->
						<!--</#if>-->
						<!--<div class="form-group">-->
							<!--<label class="col-sm-2 control-label no-padding-right" for="codekindname">书籍图片</label>-->
							<!--<div class="col-xs-9">-->
								<!--<input multiple="" name="imgFile" type="file" id="id-input-file-3" />-->

							<!--</div>-->
						<!--</div>-->
                        <div class="hr hr-16 hr-dotted"></div>
						<div style="text-align: center;">
							<button class="btn btn-info" type="button" onclick="save()">
								<i class="ace-icon fa fa-check bigger-110"></i>
								保存
							</button>
							&nbsp; &nbsp; &nbsp;
							<button class="btn" type="reset">
								<i class="ace-icon fa fa-undo bigger-110"></i>
								重置
							</button>
						</div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script>
$(document).ready(function(){

	$('#id-input-file-3').ace_file_input({
		style:'well',
		btn_choose:'文件选择',
		btn_change:null,
		no_icon:'ace-icon fa fa-cloud-upload',
		droppable:true,
		thumbnail:'small',
		preview_error : function(filename, error_code) {

		}

	}).on('change', function(){

	});

});
function save(){
	if($("#dForm").valid()){
		if($("#bid").val() !=''){
			$.confirm("确定更改？",function(){
				$('#dForm').submit();
			});
		}else{
			$('#dForm').submit();
			window.parent.alertMsg("保存成功");
            window.parent.refreshData();
		}
	}
}
</script>